% intro/motivation, rough explanation of forward and backward approaches, then outline of section
There are more than one approach to reconstructing a 3D volume from a series of 2D bscans. Two main categories of algorithms exist: \emph{pixel based} and \emph{voxel based} reconstruction. These are sometimes also called \emph{forward} and \emph{backward} reconstruction. This section explains these two approaches, with special focus on a high quality voxel-based method that takes the probe trajectory into account. These methods are used or built upon in this thesis, and thus are important to understand. A technique for accelerating voxel-based methods, called fast slice selection, is also described. The section begins with the basics of geometric transformations in space that are used in the implementation of any the reconstruction methods.

% about transformation matrices
\subsection{Geometric Transformations}

	A geometric transformation is an operation on a set coordinates. The resulting coordinates can be rotated, translated, resized relatively to each other, skewed, and so on. A practical way to represent a transformation on coordinates $\bb{P}$ is by a \emph{transformation matrix} $\bb{T}$:
	
	\begin{equation}
		\bb{S} = \bb{T} \cdot \bb{P}
		\label{eq:transformation}
	\end{equation}
	
	where $\bb{S}$ are the transformed coordinates. To make it possible to represent translation by transformation matrices, we convert $\bb{P}$ to \emph{homogenized coordinates} $\bb{P}'$ by extending it with one dimension with scalar value 1. Given that $\bb{P}$ is a vector of $N$ dimensions, then $\bb{P}'$ is of $N+1$ dimensions and $\bb{T}$ is a $N+1 \times N+1$ matrix. The product $\bb{T} \cdot \bb{P}'$ will then give a homogenized $N+1$ vector that can be converted to normal coordinates by dividing each element by the value of the added dimension. Typically this value is still 1, and we simply ommit the last dimension. 
	
	The identity matrix represent an empty transformation with no effect. The transformations used in this thesis are rotation and translation. Equations \ref{eq:transformation_matrices_0} and \ref{eq:transformation_matrices_1} gives transformation matrices for translation and rotation around the x-, y- and z- axis:
	
	\begin{equation}
		\bb{T}_{translate} =
		\left[ {\begin{array}{cccc}
		1 & 0 & 0 & x \\
		0 & 1 & 0 & y \\
		0 & 0 & 1 & z \\
		0 & 0 & 0 & 1 \\
		\end{array} } \right]
	,
		{\bb{T}_{rotate}}_x =
		\left[ {\begin{array}{cccc}
		1 & 0 & 0 & 0 \\
		0 & \cos{\theta} & -\sin{\theta} & 0 \\
		0 & \sin{\theta} & \cos{\theta} & 0 \\
		0 & 0 & 0 & 1 \\
		\end{array} } \right]
		\label{eq:transformation_matrices_0}
	\end{equation}
	\begin{equation}
		{\bb{T}_{rotate}}_y =
		\left[ {\begin{array}{cccc}
		\cos{\theta} & 0 & \sin{\theta} & 0 \\
		0 & 1 & 0 & 0 \\
		0 & 0 & 1 & 0 \\
		-\sin{\theta} & 0 & \cos{\theta} & 1 \\
		\end{array} } \right]
	,
		{\bb{T}_{rotate}}_z =
		\left[ {\begin{array}{cccc}
		\cos{\theta} & -\sin{\theta} & 0 & 0 \\
		\sin{\theta} & \cos{\theta} & 0 & 0 \\
		0 & 0 & 1 & 0 \\
		0 & 0 & 0 & 1 \\
		\end{array} } \right]
		\label{eq:transformation_matrices_1}
	\end{equation}
	
	where $(x, y, z)$ are the translations in the x-, y- and z- dimension and $\theta$ is the rotation angle. Representing combined translation and rotation is simply done by multiplying transformation matrices into one matrix:
	
	\begin{equation}
		\bb{S} = \bb{T}_{translate} \cdot {\bb{T}_{rotate}}_x \cdot {\bb{T}_{rotate}}_y \cdot \bb{P} = \bb{T}_{combined} \cdot \bb{P}
		\label{eq:transformation_combination}
	\end{equation}.
	
	The orientation of an ultrasound bscan can be represented by a transformation matrix that is given by a tracking system, which is the case in this thesis.

% what is the pixel based approach to reconstruction?
\subsection{Pixel Based Reconstruction}

	Pixel based reconstruction, also known as forward reconstruction, iterates over the ultrasound bscans and attempts to project their values into a volume. The name pixel based comes from that this approach implies that each bscan pixel is processed into a resulting volume, and since the bscans are the input and the volume is the output this is dubbed as a forward method. 
	
	For each bscan $j$ with orientation given by $\bb{T}_j$, each pixel $i$ on the bscan at location $(x_i, y_i, 0)$ with intensity $c_{j,i}$ has a contribution $V_{i,j}$ to the volume given by:
	
	\begin{equation}
		V_{i,j}(x, y, z) = m(x_i, y_i) w(|(x, y, z) - \bb{T}_j \cdot (x_i, y_i, 0)|) c_{j,i}
	\end{equation}
	
	where $w$ is a weighting function and $m$ is a 2D mask function defining a region of interest in the bscan with the value 1 inside the region and 0 outside. Examples of weighting functions include a Gaussian bell or the inverse distance:
	
	\begin{equation}
		w_{Gaussian}(x) = ae^{-{\frac{(x-b)^2}{2c^2}}}
	\end{equation}
	
	\begin{equation}
		w_{inverse}(x) = \frac{1}{x}
	\end{equation}
	
	To implement pixel based reconstruction, the following algorithm is used as basis:
	
	\begin{itemize}
		\item for each bscan $j$
		\begin{itemize}
			\item for each pixel $i$ in mask
			\begin{itemize}
				\item $v =$ the pixel coordinates transformed into the volume space
				\item for each voxel $v'$ in kernel $k$ around $v$
				\begin{itemize}
					\item set the voxel's intensity to the pixel's intensity weighted by the distance between $v$ and $v'$
				\end{itemize}
			\end{itemize}
		\end{itemize}
	\end{itemize}
	
	A number of variations of this basic algorithm exists. The size of the kernel and the definition of the weighting function can obviously be changed, and the simplest case is to let the pixel contribute to only the single closest voxel without any weighting. This is called pixel-nearest-neighbour (PNN), and its simplicity implies low computation time.
	
	A problem with PNN is that some voxels may never be filled from any pixels, and this is especially a problem when the bscans are far apart. To fix this, a hole-filling stage is required after the PNN volume filling. This is done by iterating over all unfilled voxels and set them to the average of all filled neighbours in a kernel around them. A consideration that needs to be done is what to do when an already filled voxel is to be filled from another pixel. Common approaches here are to overwrite the old value, compute an average/median or keep the maximum.

% what is the voxel based approach to reconstruction?
\subsection{Voxel Based Reconstruction}

% what is the probe trajectory method?
\subsection{Reconstruction Based on Probe Trajectory}

% what is fast slice selection?
\subsection{Fast Slice Selection}

